package com.xingda.packing.dmds.rule.choose;

import com.xingda.packing.dmds.domain.ProductBox;
import com.xingda.packing.dmds.domain.Wheel;
import com.xingda.packing.dmds.enums.BoxTaskType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component("wheelTagDMDSChoose")
@Order(6)
@Slf4j
public class WheelTagChoose implements ChooseService {
    @Override
    public boolean canChoose(ProductBox productBox, Wheel wheel) {
        boolean result = can(productBox, wheel);
        if (!result) {
            log.info("box:{}, 工字轮条码：{}，工字轮型号{}->{}", productBox.getBoxNo(), wheel.getBarCode(),productBox.getWheelTag(), false);
        }
        return result;
    }

    private boolean can(ProductBox productBox, Wheel wheel) {
        if (productBox.getType() == BoxTaskType.PACKING_CLEAN.getTypeId()) {
            return productBox.getWheelTagMap().equals(wheel.getWheelTagMap());
        }
        return productBox.getWheelTag().equals(wheel.getWheelTag());
    }
}
